<!doctype html>
<meta charset="utf-8">
<title>文件上传</title>
<style>
body { font-family: system-ui, sans-serif; padding: 24px; }
.row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
</style>
<div class="row">
  <input id="f" type="file" />
  <button id="btn">上传到 /dav</button>
</div>
<div id="msg"></div>
<script>
const f = document.getElementById('f');
const msg = document.getElementById('msg');
document.getElementById('btn').onclick = async () => {
  const file = f.files[0];
  if (!file) { msg.textContent = '请选择文件'; return }
  const url = '/dav/' + encodeURIComponent(file.name);
  const res = await fetch(url, { method: 'PUT', body: file, headers: { 'Content-Type': file.type || 'application/octet-stream' }, credentials: 'include' });
  msg.textContent = res.ok ? '上传成功：' + (location.origin + '/files/' + encodeURIComponent(file.name)) : ('上传失败：' + res.status)
}
</script>

